let dataMgr = require("./DataMgr")

cc.Class({
    extends: cc.Component,

    properties: {
        curScoreL: cc.Label,
        maxScoreL: cc.Label,
        title1: cc.Node,
        title2: cc.Node,
        reStartNode: cc.Node
    },

    onLoad() {
        let result = dataMgr.getInstance().getData("isOver");
        if (result === true) {
            this.title1.active = true;
        } else {
            this.title2.active = true;
        }
        this.curScore = dataMgr.getInstance().getData("curScore");
        this.maxScore = dataMgr.getInstance().getData("maxScore");
        this.curScoreL.string = `当前分数：${this.curScore}分`;
        this.maxScoreL.string = `最高分数：${this.maxScore}分`;
        this.reStartNode.on("click", this.onReStart, this);
        dataMgr.getInstance().saveData("roleIndex", 0);
    },

    start() {

    },

    // update (dt) {},

    onReStart() {
        cc.director.loadScene("Menu");
        console.log(dataMgr.getInstance().getData("roleIndex"));

    }
});
